$(document).ready(function () {
    $(document).ready(function (){
        $(".data-create").unbind();
        $(".data-create").click(function (){
            let url=$(this).attr("url");
            let layer_width=$(this).attr("layer-width");
            if(!layer_width){
                layer_width="80%";
            }
            let layer_height=$(this).attr("layer-height");
            if(!layer_height){
                layer_height="90%";
            }
            layer.open({
                type: 2,
                title: "",
                shadeClose: true,
                shade: 0.8,
                area: [layer_width, '90%'],
                content: url //iframe的url
            });
        });
        $(".data-view").unbind();
        $(".data-view").click(function (){
            let url=$(this).attr("url");
            let layer_width=$(this).attr("layer-width");
            if(!layer_width){
                layer_width="80%";
            }
            let layer_height=$(this).attr("layer-height");
            if(!layer_height){
                layer_height="90%";
            }
            layer.open({
                type: 2,
                title: "",
                shadeClose: true,
                shade: 0.8,
                area: [layer_width, '90%'],
                content: url //iframe的url
            });
        });
        $(".data-create").unbind();
        $(".data-create").click(function (){
            let url=$(this).attr("url");
            let layer_width=$(this).attr("layer-width");
            if(!layer_width){
                layer_width="80%";
            }
            let layer_height=$(this).attr("layer-height");
            if(!layer_height){
                layer_height="90%";
            }
            layer.open({
                type: 2,
                title: "",
                shadeClose: true,
                shade: 0.8,
                area: [layer_width, '90%'],
                content: url //iframe的url
            });
        });
        $(".data-update").unbind();
        $(".data-update").click(function (){
            let url=$(this).attr("url");
            let layer_width=$(this).attr("layer-width");
            if(!layer_width){
                layer_width="80%";
            }
            let layer_height=$(this).attr("layer-height");
            if(!layer_height){
                layer_height="90%";
            }
            layer.open({
                type: 2,
                title: "",
                shadeClose: true,
                shade: 0.8,
                area: [layer_width, '90%'],
                content: url //iframe的url
            });
        });
        $(".data-delete").click(function (){
            let url=$(this).attr("url");
            let layer_width=$(this).attr("layer-width");
            if(!layer_width){
                layer_width="80%";
            }
            let layer_height=$(this).attr("layer-height");
            if(!layer_height){
                layer_height="90%";
            }
            layer.confirm('确认删除?', {icon: 3, title:'提示'}, function(index){
                $.ajax({
                    url: url,
                    type: "POST",
                    success: function(xml, textStatus, xhr) {
                        console.log(arguments);
                        console.log(xhr.status);
                    },
                    complete: function(xhr, textStatus) {
                        if(xhr.status==302){
                            window.location.reload();
                        }
                        else {
                            layer.msg("服务器异常");
                            layer.close(index);
                        }
                    }
                });

            });
        });
    });
    setTimeout(function () {
        $(".reload").click(function() {
            $("#w0").find("input").each(function () {
                if($(this).attr("name")=="r"){
                    return;
                }
                $(this).val("");
            })
            $("select").empty();
            $("#w0").trigger("submit");
        });
    },20);

    $("#w0").find("input").each(function () {
        if($(this).attr("type")=="hidden"){
            if($(this).attr("name").indexOf("AutoSearchModle")!==-1){
                $(this).remove();
            }
        }
    })
});